package com.mrjy.common.util;

import java.util.HashMap;
import java.util.Map;

import com.mrjy.common.enums.ResultEnum;

public class ResultUtil {
	
	public static Map<String, Object> success() {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("err_code", ResultEnum.SUCCESS.getCode());
		map.put("err_msg", ResultEnum.SUCCESS.getMessage());
		return map;
	}
	
	public static Map<String, Object> success(Object data) {
		Map<String, Object> map = success();
		map.put("rows", data);
		return map;
	}
	
	public static Map<String, Object> success(Object data,int count) {
		Map<String, Object> map = success();
		map.put("rows", data);
		map.put("total", count) ;
		return map;
	}
	
	public static Map<String, Object> success(int count) {
		Map<String, Object> map = success();
		map.put("total", count) ;
		return map;
	}
	
	public static Map<String, Object> error() {
		return error(ResultEnum.ERROR);
	}
	
	public static Map<String, Object> error(Integer code, String msg) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("err_code", code);
		map.put("err_msg", msg);
		return map;
	}
	
	public static Map<String, Object> error(ResultEnum resultEnum) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("err_code", resultEnum.getCode());
		map.put("err_msg", resultEnum.getMessage());
		return map;
	}
	

}
